[dbus-c++] DBus-C++ operator overloading should rely on ADL DBus-C++ operator overloading (operator >>/<<) should rely on argument-dependent lookup, rather than on sticking the overloads in the global namespace, so that they can always be found correctly when used in templates. See http://clang.llvm.org/compatibility.html#dep_lookup to understand why the existing behaviour was incorrect BUG=none TEST=Compile against types.h with Clang Change-Id: I9239e960f6872f0f312561050d1bbd4cc9b87458 Reviewed-on: https://gerrit.chromium.org/gerrit/42027 Tested-by: Liam McLoughlin <lmcloughlin@chromium.org> Commit-Queue: Ryan Sleevi <rsleevi@chromium.org> Reviewed-by: Ryan Sleevi <rsleevi@chromium.org>
diff --git a/include/dbus-c++/types.h b/include/dbus-c++/types.h index 72606f6..fb73ce5 100644 --- a/include/dbus-c++/types.h +++ b/include/dbus-c++/types.h
@@ -191,8 +191,6 @@ } }; -} /* namespace DBus */ - extern DXXAPI DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Variant &val); inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Invalid &) @@ -526,5 +524,6 @@ return cast; } - +} /* namespace DBus */ + #endif//__DBUSXX_TYPES_H
diff --git a/src/types.cpp b/src/types.cpp index 9d61d44..9ccc000 100644 --- a/src/types.cpp +++ b/src/types.cpp
@@ -34,7 +34,7 @@ #include "message_p.h" #include "internalerror.h" -using namespace DBus; +namespace DBus { Variant::Variant() : _msg(CallMessage()) // dummy message used as temporary storage for variant data @@ -103,3 +103,5 @@ return ++iter; } + +} /* namespace DBus */ diff --git a/tools/xml.cpp b/tools/xml.cpp index 68ae5a6..d85bfd8 100644 --- a/tools/xml.cpp +++ b/tools/xml.cpp
@@ -28,6 +28,10 @@ #include <expat.h> +namespace DBus { + +namespace Xml { + std::istream &operator >> (std::istream &in, DBus::Xml::Document &doc) { std::stringbuf xmlbuf; @@ -42,9 +46,6 @@ return out << doc.to_xml(); } -using namespace DBus; -using namespace DBus::Xml; - Error::Error(const char *error, int line, int column) { std::ostringstream estream; @@ -313,3 +314,6 @@ doc->_depth--; } +} /* namespace Xml */ + +} /* namespace DBus */ diff --git a/tools/xml.h b/tools/xml.h index 6a8e69c..00e9041 100644 --- a/tools/xml.h +++ b/tools/xml.h
@@ -132,11 +132,11 @@ int _depth; }; +std::istream &operator >> (std::istream &, DBus::Xml::Document &); +std::ostream &operator << (std::ostream &, DBus::Xml::Document &); + } /* namespace Xml */ } /* namespace DBus */ -std::istream &operator >> (std::istream &, DBus::Xml::Document &); -std::ostream &operator << (std::ostream &, DBus::Xml::Document &); - #endif//__DBUSXX_XML_H